home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15446 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  53 lines

  1. Path: news.mindlink.net!news
  2. From: Allan_Nienhuis@mindlink.bc.ca (Allan Nienhuis)
  3. Newsgroups: comp.lang.c,comp.lang.c++
  4. Subject: Re: H E L P
  5. Date: Fri, 05 Apr 1996 15:32:24 GMT
  6. Organization: MIND LINK! - British Columbia, Canada
  7. Message-ID: <4k3e8g$4e4@fountain.mindlink.net>
  8. References: <N.040296.013047.18@DynamicPPP-185.HIP.CAM.ORG> <Pine.A32.3.91.960402135001.121719B-100000@green.weeg.uiowa.edu> <4js6jh$ndr@solutions.solon.com> <DpAx1J.4n9@iquest.net>
  9. NNTP-Posting-Host: line012.abb.mindlink.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. dlmiller@iquest.net (Doug Miller) wrote:
  13.  
  14. >seebs@solutions.solon.com (Peter Seebach) wrote:
  15. [snip]
  16. >>This is a bit strong.  You don't *need* a loop.  You just probably want one.
  17. >>
  18. [snip]
  19. >Obviously you didn't read what he wrote.  To satisfy the conditions of the task as he stated it,
  20. >he would need an infinite number of ifs ("whatever number I enter...").  I saw nothing in his
  21. >statement of the task that placed any limits of any sort on the number -- thus, he *does* need
  22. >a loop.
  23.  
  24. Sorry, your wrong.  Try this:
  25.  
  26. ////////////////////////////////////////////////////////////////////////////////
  27. #include <stdlib.h>
  28. #include <iostream.h>
  29.  
  30. void main()
  31. {
  32. long i = 0;
  33. char Happyface = '▄';
  34. char  far *String;
  35.  
  36. do
  37.     {
  38.     cout << "number? (0 to end) >"; cin >> i;
  39.     if(!(String = new char[i])) break;
  40.     _fmemset(String,Happyface,i);
  41.     String[i]=NULL;
  42.     cout << String << "\n\n";
  43.      delete[] String;
  44.     } while (!(i==0));
  45.  
  46. cout << "Have a nice day! ▄\n"; 
  47. }
  48. ////////////////////////////////////////////////////////////////////////////////
  49.  
  50. I know, memset uses a loop, but HE doesnt' need to!
  51.  
  52.  
  53.